### FILE="Main.annotation"
# Copyright:	Public domain.
# Filename:	REENTRY_CONTROL.agc
# Purpose:	Part of the source code for Solarium build 55. This
#		is for the Command Module's (CM) Apollo Guidance
#		Computer (AGC), for Apollo 4.
# Assembler:	yaYUL --block1
# Contact:	Jim Lawton <jim DOT lawton AT gmail DOT com>
# Website:	www.ibiblio.org/apollo/index.html
# Page scans:	www.ibiblio.org/apollo/ScansForConversion/Solarium055/
# Mod history:	2009-09-30 JL	Created.

## Page 698

		SETLOC	56000

# 	THE PIPUP SECTION IS A TASK WHICH READS THE PIPAS EVERY .5
# SECONDS. ACCELERATION HISTORY OVER THE LAST TWO SECONDS (FOUR READINGS)
# IS MAINTAINED  IN THE XPIPBUF, YPIPBUF, AND ZPIPBUF REGISTERS. EACH PIPA
# READING IS SUMMED INTO THE XPIPSUM ETC. REGISTERS, AND EVERY FOURTH READ
# ING AVERAGE G IS CALLED TO USE THE SUMMED READINGS TO UPDATE POSITION
# AND VELOCITY AND SET THE PIPSUM REGISTERS TO ZERO.
#
#   GOES THRU PIPUP ONLY ONCE EVERY 2 SEC.  (ELSEWHERE MORE OFTEN.)

		CADR	REPIPASR
REPIPUP		CAF	-1
		TC	PIPUP +1	# REREAD PIPAS IF NECESSARY.
		
		CADR	PIPASR
PIPUP		CAF	-1
		TC	ISWCALL		#  GO TO PIPAREAD SUBROUTINE.
		
		CAF	THIRTN		# PICK UP AT REDO5.13
		TC	NEWPHASE
		OCT	5		# 5.13 RESTART.  (NO TIME CALL.)
		
REDO5.13	CAF	DT
		TC	WAITLIST
		CADR	PIPUP
		
		CS	PIPTIME +1
		TS	TBASE5		# SAVE NEW TIME.
		
		CAF	IPIPDT
		TC	WAITLIST
		CADR	INTERPIP	# READ ACCELERATION MORE OFTEN.
		
		CAF	PRIO16
		TC	FINDVAC
		CADR	ENTRYTOP
		
		CAF	TWO
		TS	PIPCTR
		
		CAF	FOURTN		# THIS WILL PICK UP AT ENTRYTOP + 3.
		TC	NEWPHASE
		OCT	5		# 5.14 RESTART.
		
		TC	TASKOVER



IPIPDT		DEC	50

## Page 699

#	JOB WHICH PROCESSES PIPA READINGS TO UPDATE POSITION AND VELOCI

ENTRYTOP	XCH	TENTRY		# UPDATE ENTRY TIME.
		AD	TWO
		XCH	TENTRY		# IN SECS SINCE START OF ENTRY.
		
		CAF	ONE
		TS	PIPAGE
		
		CS	DELVX
		TS	XPIPBUF +3
		CS	DELVY
		TS	YPIPBUF +3
		CS	DELVZ		# SAVE PIP COUNTS.
		TS	ZPIPBUF +3
		
		TC	PHASCHNG
		OCT	01705		# 5.15 RESTART PICKS UP AT REFAZE4.
		TC	BANKCALL	# COMPENSATE THE PIPA DATA
		CADR	1/PIPA
		
REFAZE4		TC	INTPRET

		ITC	0		# GO TO AVERAGE G INTEGRATION ROUTINES TO
			CALCRVG		# USE PIPA READINGS TO UPDATE POSIITON AND
					# VELOCITY.
		TC	PHASCHNG
		OCT	02105		# 5.17 RESTART AT REFAZE8.
		
REFAZE8		TC	INTPRET

## Page 700

#  PROCESS AVERAGE G OUTPUT...SCALE IT AND GET INPUT DATA

SCALEPOP	VXSC	0
			VPIP		# KVSCALE = (12800/.3048)0(25766.1973 X2)
			KVSCALE		# KVSCALE = .81491944
		STORE	(V)		# V VECTOR
		
		TEST	2
		VXV	VXSC		# (VREL) = (V) + KWE UNITR*UNITW
		VAD
			RELVELSW	# SWITCH NUMBER.
			GETUNITV
			UNITR
			UNITW
			KWE
			(V)
		STORE	(V)		# NEW VECTOR IS RELATIVE.

GETUNITV	NOLOD	1
		UNIT
		STORE	UNITV		# HALF MAX. OF COURSE.
		
		TSLT	0
			28D		# RESCALE MAGNITUDE SQUARED.
			2		# SHIFT COUNT.  (2 BECAUSE HALF-LEN SQRD
		STORE	VSQUARE
		
		DSU	0
			VSQUARE
			FOURTH
		STORE	LEQ
		
		TSLT	0
			30D
			1
		STORE	V
		
		DOT	1
		TSLT
			(V)
			UNITR
			1
		STORE	RDOT
## Page 701
		DMOVE	0		#  SAVE OLD DRAG VALUE.
			D
		STORE	DOLD
		
		ABVAL	2
		TSLT	DMP
		BZE
			DELV		# KASCALE=5.85 16384/(4 .3048 805 100)
			2		# 2 FOR 2 SEC,  3 FOR 1 SEC, 4 FOR  .5 --
			KASCALE		#  = 3.   /4                       /25
			SETMIND
		STORE	D		# ACCELERATION   (DRAG, ALMOST)
		
GETUNI		VXV	1		# UNI = UNIT(V*R)
		UNIT
			(V)		# COULD USE UNITV.
			UNITR
		STORE	UNI		# INERTIAL OR RELATIVE AS IS (V).

# 	SOME OF THE FOLLOWING TARGETTING MIGHT BE DONE LESS OFTEN THAN ABOVE.

		TEST	1		# THIS TEST MIGHT BE COMBINED WITH  THE
		DMOVE			# PREVIOUS ONE IF ALL CALCULATIONS ARE
			RELVELSW	# DONE EVERY CYCLE.
			GETETA
			PIPTIME
		STORE	DTEARROT

##  Page 702

UPDATERT	ITC	0		# UPDATE PREDICTED TARGET VECTOR RT
			EARROT2
		
		NOLOD	1
		DOT	RTB		# SINCE (RT) UNIT VEC, THIS IS 1/4 MAX.
			UNI		# LATANG = RT.UNI
			FRESHPD
		STORE	LATANG		# LATANG = MAC LATANGLE/4 (NO 2 PI)
					# UNUSUAL SCALING FOR LATANG. ( = ASIN L.
		
GETANGLE	DOT	3		# THETA = ARCOS(RT.UNITR)
		DSU	BPL		# RT IS UNIT VECTOR
		DAD	TSLT
		ACOS
			RT
			UNITR
			NEAR1/4		# TO IMPROVE ACCURACY, CALC RANGE BY
			TINYTHET	# TINYTHET IF HIGH ORDER PART OF
			NEAR1/4		# ARCCOS ARGUMENT IS ZERO
			1
		STORE	THETAH
		
		EXIT	0

REFAZE10	TC	PHASCHNG
		OCT	02205		# 5.18 RESTART AT REFAZE10
		TC	INTPRET
## Page 703

#	JUMP TO A PARTICULAR RE-ENTRY PHASE.

SEQUENCE	ITCI	0		# BRANCHES TO VARIOUS CONTROL PHASES.
			GOTOADDR	# ADDRESS OF PHASE EQS STORED HERE.

#	GOTOADDR CONTAINS THE ADDRESS OF THE ROLL COMMAND EQUATIONS 
# APPROPRIATE TO THE CURRENT PHASE OF RE-ENTRY.  SEQUENCING IS AS FOLLOWS:
#
# INITROLL SET HERE INITIALLY. HOLDS INITIAL ROLL ATTITUDE UNTIL KAT  EX-
# 	   CEEDED. THEN HOLDS NEW ROLL ATTITUDE UNTIL VRTHRESH EXCEEDED.  
#	   THEN BRANCHES TO
#
# HUNTEST  THIS SECTION CHECKS TO SEE IF THE PREDICTED RANGE AT NOMINAL
#	   L/D FROM PRESENT CONDITIONS IS LESS THAN THE DESIRED RANGE.
#	     IF NOT-- A ROLL COMMAND IS GENERATED BY THE CONSTANT DRAG 
#	     CONTROLLER.
#	     IF SO-- CONTROL AND GOTOADDR ARE SET TO  UPCONTRL
#	   USUALLY NO ITERATION IS INVOLVED EXCEPT IF THE RANGE DESIRED IS 
#	   TOO LONG ON THE FIRST PASS THRU HUNTEST.
#
# UPCONTRL CONTROLS ROLL DURING THE SUPER-CIRCULAR PHASE. UPCONTRL IS TERM
#	   INATED EITHER (A) WHEN THE DRAG (AS MEASURED BY THE PIPAS) 
#	   FALLS BELOW Q7, OR (B) IF RDOT IS NEGATIVE AND REFERENCE VL 
#	   EXCEEDS V.  IN CASE (A), GOTOADDR IS SET TO KEP2 AND IN (B) TO
#	   PREDICT3, SKIPPING THE KEPLER PHASE OF ENTRY.
#
# KEP2	   GOTOADDR IS SET HERE DURING THE KEPLER PHASE TO MONITOR DRAG. 
#	   SPACECRAFT IS INSTANTANEOUSLY TRIMMED IN PITCH AND YAW TO THE 
#	   COMPUTED RELATIVE VELOCITY VECTOR.  THE LAST COMPUTED ROLL 
#	   ANGLE IS MAINTAINED.  WHEN THE MEASURED DRAG EXCEEDS Q7+.5,
#	   GOTOADDR IS SET TO
#
# PREDICT3 THIS CONTROLS THE FINAL SUB-ORBITAL PHASE. ROLL COMMANDS CEASE
#	   WHEN V IS LESS THAN VQUIT.  AN EXIT IS MADE TO TERMALT WHEN
#	   TERMINAL ALTITUDE IS REACHED.

## Page 704

#	OUT OF SEQUENCE SUBSECTION TO COMPUTE ETA.

		BANK	30
GETETA		TEST	1
		DMP			# NOT USED AT LOW VEL WHERE THETA NEG.
			EGSW
			SUBETA		# BRANCHES IF INTO EQ. GLIDE PHASE.
			THETAH
			KTETA		#  = 1000X2PI/(2)E14 163.84
		STORE	ETA		# DONT REALLY WANT IT, BUT NO PUSH WANTED
		
GETETA2		NOLOD	1
		DAD
			PIPTIME
		STORE	DTEAROT
		
		ITC	0
			UPDATERT
		
SUBETA		DSU	1		# SWITCH FROM INERTIAL TO RELATIVE
		BPL	SWITCH		# VELOCITY WHEN V LESS THAN .5 VSAT.
			V
			FOURTH
			SUBETA2
			RELVELSW	# SHOULD CHANGE TO OFF (NON-BRANCH) STATE

SUBETA2		DMP	1
		DDV	ITC
			THETAH
			KT		# KT = RE(2 PI)/ 2 VS 16384 163.84
			V		#                        /2 VSAT
			GETETA2

SETMIND		DMOVE	0		# MAKE D NON-ZERO.
			1BITDP
		STORE	D
		
		ITC	0
			GETUNI

TINYTHET	NOLOD	3		# ENTER WITH  X-.249
		DSU	ABS		# GET 1/4 - MPAC
		TSLT	SQRT		# SCALE UP BEFORE SQRT.
		DMP			# HAS FACTOR FOR UP SCALING.
			1BITDP +1	# X = SQRT(2(1-COSX)),   IN RADIANS
			13D		# X/2PI=(1/64PI)(SQRT(((1-COSX)/4)2EXP13)
			KACOS
		STORE	THETAH
		
		RTB	0		# OFF TO PRE-SEQUENCE...
## Page 705
			REFAZE10

## Page 706

# 	MAINTAINS INITIAL ROLL UNTIL D = KAT, GOES INTO HUNTEST WHEN
# RDOT = VRCONT.



		BANK	31

KEPCADR1	CADR	KEP2
HUNTCADR	CADR	HUNTEST

INITROLL	DMOVE	0
			INITL/D
		STORE	L/D
		
		TEST	2		# IF D-.05 G NEG, GOT TO LIMITL/D
		DSU	BMN		#  IF NOT, SET .05 G SWITCH FOR SCS
		EXIT
# RDOT = VRCONT.


			INRLSW
			INITRL1
			D
			.05G
			LIMITL/D
		
		TC	RELAYON		# SEND .05 G SIGNAL TO SCS.
		OCT	40100
		TC	NEWMODE		# SET MODE TO AFTER .05 G STATE.
		OCT	00064
		TC	INTPRET
		
		DMOVE	0		# MAY WANT THIS IN UPDWNTST FOR 278
			LAD
		STORE	L/D
		
		NOLOD	0
		STORE	INITL/D
		
		SWITCH	2		# IF V-FINAL NEG, GO TO FINAL PHASE
		DSU	BPL
		EXIT
			INRLSW
			V
			VFINAL
			UPDWNTST
		
		CAF	KEPCADR1
		TS	GOTADDR
## Page 707
		TC	INTPRET
		
		ITC	0
			LIMITL/D

UPDWNTST	DDV	0
			RDOT
			V		# RESULT INTO PD
		
		NOLOD	5		# IF V-VFINAL+K(RDOT/V)CUBED POS,L/D=-LAD
		DSQ	DMP
		DDV	DSU
		DAD	BOV
		BMN	LODON
		COMP
			-
			K44
			VFINAL
			V
			LIMITL/D
			LIMITL/D
			LAD
		STORE	INITL/D
		
		NOLOD	0
		STORE	L/D
		
		ITC	0
			LIMITL/D

INITRL1		DSU	2		# IF KAT-D POS, GO TO OUT WITH COMMAND
		BPL	LODON		#     IF NEG,  L/D = LAD
		DMOVE
			KAT
			D
			VRTHRES
			LAD		# WHEN D GREATER THAN KAT, L/D = LAD
		STORE	L/D
		
VRTHRES		DAD	1		# IF RDOT + VRCONT NEG, GO TO STEER
		BMN	EXIT		# IF POS, SET SELECTOR TO HUNTEST.
			RDOT
			VRCONT
			LIMITL/D	#  DO LATERAL CONTROL IF NEEDED.
					#				SPACER
		CAF	HUNTCADR
		TS	GOTOADDR	# AND FALL THRU INTO HUNTEST.

## Page 708

#  ... HUNTEST SECTION... CHECKS TO SEE WHEN PREDICTED RANGE = DESIRED ONE
#
#					KEEP WITH ABOVE CODING........

		TC	INTPRET
		
HUNTEST		DMOVE	0
			LEWD1
		STORE	LEWD
		
		DSU	2
		BMN	LODON
		DMOVE
			D
			C20
			HUNTESTA
			LEWD2
		STORE	LEWD
		
		DMOVE	0
			D		# A1 = D
		STORE	A1
		
HUNTESTA	DMOVE	0		#  IF RDOT POS, TEM1B = LAD
			LAD
		STORE	TEM1B
		
		BMN	1
		LODON	DMOVE
			RDOT
			A0CALC
			LEWD
		STORE	TEM1B
		
A0CALC		DDV	1		# V1 = V + RDOT/TEM1B
		DAD
			RDOT
			TEM1B
			V
		STORE	V1
		
		DSQ	3		# A0=(V1/V)SQ(D0+RDOT SQ/(TEM1B 2 C1 HS)
		DDV	DDV
		DAD	DMP
		DMP	DDV
			RDOT
			TEM1B
			2C1HS
			D
			V1
## Page 709
			V1
			VSQUARE
		STORE	A0
		
		BPL	0		# IF RDOT NEG, A1 = A0
			RDOT
			TESTHSW
		
		DMOVE	0
			A0
		STORE	A1

TESTHSW		TEST	1		# IF HUNTSW1 ON (BRANCH), GO TO HUNTEST1
		SWITCH
			HUNTSW1
			HUNTEST1
			HUNTSW1
		
		DMOVE	0		# ZERO DIFFOLD THE FIRST TIME THRU.
			3ZEROS
		STORE	DIFFOLD
		
		DAD	0		# V1OLD = V1 + C18  (500FPS)
			V1		# MAKES OLD VCORR -500 AND NEW +500 ..
			C18		# INITIAL VALUE ON VCORR = -500 FPS SO
		STORE	V1OLD		# (IN+TIAL 0ALUES IF NEEDED ON 1ST PASS.
		
		DMOVE	0		# Q7 = Q7F
			Q7F
		STORE	Q7
		
HUNTEST1	DMP	2		# ALP = A0 2HSD/LWD / V1 V1
		DDV	RTB
		DDV	DDV
			A0
			2C1HS
			V1
			FRESHPD
			V1
			LEWD
		STORE	ALP
		
		NOLOD	1
		BDSU	BDDV
			NEARONE		# FACT1 = V1 / (1 - ALP)
			V1
		STORE	FACT1
		
		DSU	1
		DMP	DDV		# FACT2 = ALP(ALP - 1) / AD
## Page 710
			ALP
			NEARONE
			ALP
			A0
		STORE	FACT2
		
		DMP	2		# VL = FACT1(1 - SQRT(ALP + Q7 FACT2))
		DAD	SQRT
		BDSU	DMP
			Q7
			FACT2
			ALP
			NEARONE
			FACT1
		STORE	VL
		
		NOLOD	2		# GAMMAL = LEWD(V1-VL)/VL
		BDSU	DMP
		DDV
			V1
			LEWD
			VL
		STORE	GAMMAL1		# GAMMAL1 USED IN UPCONTRL
		
		DSU	1		# IF VL-VMIN NEG, GO TO SHORT
		BMN
			VL
			VMIN
			PREFINAL	# PREFINAL = SHORT
		
		DSQ	0		# VBARS = VL VL
			VL
		STORE	VBARS
		
		DSU	1		# IF VSAT - VL NEG, GO TO CONSTD.
		BMN
			HALVE		# VSAT = .5
			VL
			BECONSTD	# GOTOADDR MAY BE SIDETRACKED.
		STORE	DVL		# DVL = VSAT - VL
		
		DMOVE	0
			HALVE		# VS = VSAT
		STORE	VS
		
		NOLOD	2
		DSU	BMN		# IF V1 GREATER THAN VSAT, GO ON.
		BDSU
			V1
			GETDHOOK
## Page 711
			DVL		# DVL = DVL - (VSAT-V1) = V1 - VL
		STORE	DVL
		
		DMOVE	0
			V1
		STORE	VS		# VS = V1
		
GETDHOOK	TSRT	3		# DHOOK = ((1-VS/FACT1)SQ -ALP)/FACT2
		DDV	BDSU
		TSLT	DSQ
		DSU	DDV
			VS
			1
			FACT1
			HALVE
			1
			ALP
			FACT2
		STORE	DHOOK
		
		TSRT	1		# RESCALE BY 32.
		DDV	DSU
			DHOOK
			5
			Q7
			CHOOK
		STORE	AHOOKDV
		
		NOLOD	4
		DAD	DMP		# GAMMAL = GAMMAL1-CH1 DVLSQ(1+AHOOK DVL
		DMP	DMP		#        /DHOOK VBARS
		DDV	DDV
		BDSU	BMN
			1/8TH
			CH1
			DVL
			DVL
			DHOOK
			VBARS
			GAMMAL1
			NEGAMA		# FIND CONDITIONS FOR GAMMAL = 0.
		STORE	GAMMAL
## Page 712

#   ... PREDICT RANGES FOR EACH PHASE OF TRAJECTORY...

RANGER		DSQ	1
		TSRT	BDSU		# COSG = 1-GAMMAL SQ/2 , TRUNCATED SERIES
			GAMMAL
			2
			HALVE
		STORE	COSG/2
		
		DSU	3
		DMP	DMP		# E=SQRT(1+VBARS-2)VBARS COSG COSG)
		DMP	TSLT
		DAD	SQRT
			VBARS
			HALVE
			VBARS
			COSG/2
			COSG/2
			2		# MULT BY 4
			C1/16		# E  (E/4 REALLY) INTO PD.
		
		DMP	2		# ASKEP/2 = ARCSIN(VBARS COSG SING/E)
		DMP	DDV
		ASIN	TSLT
			VBARS
			COSG/2
			GAMMAL
			-		# E FROM PD.
			1		# ASKEP INTO PD.
		
		DMP	1		# ASP1 = Q2 +Q3(VL-Q4) = Q2' + Q3 VL
		DAD	DAD
			VL
			Q3
			Q2		# ASP1 + ASKEP INTO PD.
		
		DMP	0		# MODIFY GAMMAL1
			GAMMAL1
			POINT8
		DMP	1
		DAD
			GAMMAL
			POINT2
		STORE	GAMMAL1
		
		DSQ	3		# ASPUP = -C12 LOG(V1 V1 Q7/VBARS D)/GAN
		DMP	DDV		#                                AL1
		DDV	RTB
		DMP	DDV
			V1
## Page 713
			Q7
			VBARS
			A0
			LOG
			C12
			GAMMAL1
		
		DMP	1
		DMP	DDV
			KC3
			RDOT
			V
			A0
		
		DSU	2
		DMP	DAD
		DAD	DAD
			Q6
			GAMMAL
			Q5
		
		NOLOD	1
		BDSU	TSRT
			THETAH
			4
		STORE	DIFF
		
		NOLOD	4
		ABS	DSU
		BMN	TEST
		LODON	BMN
		LODON	DSU
			25NM
			GOTOUPSY
			HIND
			GETVCOR
			DIFF
			DCONSTD
			
			V1
			V1OLD
		STORE	VCORR
		
GETVCOR		DSU	2
		TSRT	DDV
		BDDV	TSRT
			DIFFOLD
			DIFF
			2
			VCORR
## Page 714
			DIFF
			2
		STORE	VCORR
		
		EXIT	0
		
		TC	PHASCHNG	# HAVE GROUP 3 PICK UP AT PREHUNT.
		OCT	02003		# 3.16 RESTART.
		
		CAF	ADENDEXT	# SIDETRACK NEXT PASS UNTIL THIS ONE DONE.
		TS	GOTOADDR	# ONLY AFTER RESTART IS LEFT AFTER DETOUR.
		
		CAF	ZERO		# ZERO OVFIND TO GUARD AGAINST FUTURE BOV
		TS	OVFIND
		
		TC	INTPRET
		
		NOLOD	2
		BDSU	BPL		# IS VCORR - 1000 POS.
		DAD			# VCORR = 1000
			VCORLIM
			CHKVL
			VCORR		# LEAVING VCORLIM IN MPAC
		STORE	VCORR
		
CHKVL		DAD	2
		DSU	BMN		# IF VL + VCORR - VSAT POS, VCORR=VCORR/
		LODON	TSRT
			VCORR
			VL
			HALVE
			GETNUV1
			VCORR
			1
		STORE	VCORR
		
GETNUV1		DAD	0
			V1
			VCORR
		STORE	V1
		
		DMOVE	0		# SAVE OLD VALUE OF ASP
			DIFF
		STORE	DIFFOLD
		
		TEST	1		# SET HIND AND GO TO HUNTEST1
		SWITCH	ITC
			HIND
			HUNTEST1
			HIND
## Page 715
			HUNTEST1



NEGAMA		NOLOD	1		# ENTER WITH GAMMAL IN  MPAC
		DMP	DMP		# FIND GAMMAL VL / 3
			VL
			1/3RD		#   .. AND PUSH DOWN PARTIAL RESULT..

		DMP	0
			LEWD
			1/3RD		# PUSH LEWD/3 ALSO
		DAD	3
		DMP	DMP		#  DEL VL = GAMMAL VL/3)/(LEWD/3 - DVL(2/3
		DDV	DDV		#      + AHOOKDV)(CH1 GS/DHOOK VL1))
		BDSU	BDDV
			AHOOKDV
			1/12TH
			DVL
			CH1
			DHOOK
			VL		# 2 OUT OF ,1 INTO PUSH
		
		DAD	0
			VL
		STORE	VL		#  VL = VL + DEL VL
		
		NOLOD	3		#  VL IS IN MPAC
		DDV	BDSU		#  Q7 = ((1-VL/FACT1)SQ - ALP)/ FACT2
		DSQ	DSU
		DDV
			FACT1
			NEARONE
			ALP
			FACT2
		STORE	Q7
		
		DSQ	0		# GET NEW VBARS.
			VL
		STORE	VBARS
		
		DMOVE	0
			3ZEROS
		STORE	GAMMAL		#  GAMAL = 0
		
		ITC	0
			RANGER

## Page 716

ADENDEXT	CADR	ENDEXIT

PREHUNT		TC	STATEUP		# SET HUNTSW1 AND HIND SWITCHES
		OCT	00140
		
		TC	HUNTEST -1
		
		BANK	27
		
UPCADR		CADR	UPCONTRL

GOTOUPSY	EXIT	0		# BACK TO BASIC

HUNTDUMP	CAF	UPCADR		# RESET GOTOADDR
		TS	GOTOADDR
		TC	NEWMODE		# CHANGE MODE TO SIGNAL END OF HUNT-TEST.
		OCT	00065
		
		CS	ONE		# MAKE GROUP 3 INACTIVE WHEN DONE WITH
		TC	NEWPHASE	# 	THE ITERATIONS.
		OCT	3		# GROUP 3.
		
		CS	FIXLOC		# RESET PUSHDOWN POINTER
		COM
		TS	PUSHLOC
		
		TC	INTPRET		# ...AND FALL INTO UPCONTROL...

## Page 717

# THIS SECTION IS THE UPCONTROL FOR THE SUPERCIRCULAR PHASE

UPCONTRL	DSU	3		# IF V-V1 POS, GO TO DOWNCONTROL
		BPL	LODON		# IF D-Q7 NEG, GO TO KEP
		DSU	BMN
		LODON	BMN		# IF RDOT NEG, GO TO VLTEST
			V		# VLTEST TESTS FOR START OF FINAL PHASE
			V1
			DOWNCNTL
			D
			Q7
			KEP		# SET CONSTS. ETC FOR BALLISTIC PHASE.
			RDOT
			VLTEST

CONT1		DSU	1
		BPL
			D		# IF D-A0 NEG,L/D=LAD,GO TO 310
			A0
			GOPOSLAD
		DMP	2		# VREF=FACT1(1-SQRT(FACT2 D + ALP))
		DAD	SQRT
		BDSU	DMP
			D
			FACT2
			ALP
			NEARONE
			FACT1
		STORE	VREF
		
		NOLOD	1		# RDOTREF = LEWD(V1-VREF)
		BDSU	DMP
			V1
			LEWD
		STORE	RDOTREF
		
		DSU	1		# IF VSAT - VREF NEG, GO TO CONTINU2
		BMN	NOLOD		# NOLOD TO PUSH DOWN (HALVE-VREF)
			VS
			VREF		# NO RDHOOK UNTIL VREF LESS THAN VSAT.
			CONTINU2	# PUSHING DOWN IF NO BRANCH.
		
		NOLOD	5		# RDHOOK=CH1(AHOOKDVL/DVL(DV+1))DV DV
		DMP	DDV		#       /DHOOK VREF
		DAD	DMP		# WHERE DV = VS - VREF
		DMP	DMP
		DDV	DDV
		BDSU
			AHOOKDV
			DVL
## Page 718
			1/8TH
			CH1
			0		#  ABOVE SHOULD HAVE PUSHED INTO LOC 0.
			-
			DHOOK
			VREF
			RDOTREF
		STORE	RDOTREF		#  RDOTREF = RDOTREF - RDHOOK
		
CONTINU2	DSU	1		# BYPASS FACTOR CALC, IF D-Q7MIN NEG.'
		BMN
			D
			Q7MIN
			CONTINU3
		
		DSU	0
			A1		# FACTOR = (D-Q7)/(A1-Q7)
			Q7		#  PARTIAL RESULT IN PD
		
		DSU	1
		DDV
			D
			Q7
		STORE	FACTOR

CONTINU3	DSU	3		# L/D = LEWD
		DMP	DDV		#  -((RDOT-RDOTREF)F1/KB1+V-VREF)F1/KB2
		DAD	DSU
		DMP	DDV
			RDOT
			RDOTREF
			FACTOR
			KB1
			V
			VREF
			FACTOR
			KB2		# DELTA L/D INTO PD
		
		BOV	3		# NONLINEAR CIRCUIT FOR REDUCING HIGH
		ABS	DSU		# GAINS HERE
		BMN	DMP
		DAD	SIGN
			GOMXL/D1
			0
			PT1/16
			NEXT1
			POINT1
			PT1/16
NEXT1		TSLT	1
		DAD	BOV
## Page 719
			-
			4
			LEWD
			GOMXL/D1	# PUSHES IF NO BRANCH, NO MATTER

NEGTESTS	NOLOD	0
		STORE	L/D
		
		NOLOD	3		# IF L/D NEG, AND D-C20 POS, L/D = 0
		BPL	LODON
		DSU	BMN
		DMP
			LIMITL/D
			D
			C20
			LIMITL/D
			3ZEROS		# L/D=0 NO NEG LIFT
		STORE	LIMIT/D

GOMXL/D1	RTB	1
		DMP	ITC
			SIGNMPAC
			LAD
			NEGTESTS

## Page 720

#	CONSTANT DRAG CONTROLLER
DCONSTD		DMOVE	0
			DIFF		# SAVE OLD VALUE OF DIFF FOR NEXT PASS.
		STORE	DIFFOLD
		
		DMOVE	0		# V1OLD = V1
			V1
		STORE	V1OLD
		
BECONSTD	AXT,1	1		# RESETS GOTOADDR  TO GO TO HUNTEST
		RTB	SXA,1
			HUNTEST
			FRESHPD
			GOTOADDR

CONSTD		DMP	0
			LEQ
			C/D0		# C/D0 LEQ INTO PD
		
		DMP	2
		DDV	DAD
		DMP	DAD
			2HS		# RDOTREF = - 2 HS D0/V
			C19		# D0 = C19
			V
			RDOT
			K2D		# C/D0 LEQ + K2D(RDOT-RDOTREF) INTO PD
		
		DMOVE	0
			C19
CONSTD1		DSU	3
		DMP	DAD
		TSLT	BOV
		ITC
			D
			-
			K1D
			-
			8D
			GOMXL/D1
			NEGTESTS

DOWNCNTL	DSU	2		# RDTR = LAD(V1-V)
		DMP	DAD
		DMP	DAD
			V
			V1
			LAD
			RDOT
			K2D
## Page 721
			LAD/256		# LAD + K2D(RDOT-RDTR) INTO PD
		
		DSU	1
		DSQ	DDV
			V1
			V
			2CH1SLAD	# (V1-V)SQ/(2 C1 HS/LAD) INTO PD
		
		DSQ	2		# DREF = (V/V1)SQ A0 - PD
		DDV	BDDV
		DSU
			V1
			VSQUARE
			A0
		
		ITC	0
			CONSTD1
		
KEP		EXIT	0
		
		CAF	KEPCADR		# SET GOTOADDR TO KEPLER PHASE.
		TS	GOTOADDR
		TC	NEWMODE		# SET MODE TO KEPLER PHASE.
		OCT	00066
		
		TC	INTPRET
		
KEP2		DSU	1
		BMN	EXIT
			D
			.05G
			NO.05G
		
		TC	RELAYON
		OCT	40100		# SEND .05G INDICATION
		TC	INTPRET
		
KEP3		DAD	1		# IF Q7+KDMIN - D NEG, GO TO FINAL PHASE
		DSU	BMN
			Q7		#  MIN DRAG = Q7 + .5 FT/SEC/SEC
			KDMIN
			D
			PREFINAL	#  FALL THRU IF POS...

ENDEXIT		EXIT	0		#  GOTOADDR IS SET HERE DURING VLHUNT.
		TC	OVERNOUT
		
NO.05G		EXIT	0
		TC	RELAYOFF	# REMOVE .05G INDICATION
		OCT	40100
## Page 722
		TC	KEP3 -1

KEPCADR		CADR	KEP2
P3CADR		CADR	PREDICT3

VLTEST		DSU	1		# IF V-VL-C18 NEG,EGSW=1,SELECTOR=PREDIC
		DSU	BPL		# GO TO PREDICT3
			V
			VL
			C18
			CONT1

PREFINAL	SWITCH	1		# CHANGE GOTOADDR TO PREDICT3 AND FALL
		EXIT			# INTO PREDICT3
			EGSW
		
		CS	ONE
		TC	NEWPHASE
		OCT	3
		
		CAF	P3CADR
		TS	GOTOADDR	# SET TO PREDICT3 PHASE.
		TC	NEWMODE
		OCT	00067
		
		TC	INTPRET		# ... AND FALL INTO PRDICT3...

## Page 723

#   SUBORBITAL CONTROL  (REFERENCE TRAJECTORY BY TABLE LOOKUP.)

PREDICT3	DSU	4
		BMN	LODON		# IF V - VQUIT NEG,  STOP STEERING
		TEST
		VXV	DOT		# IF (RT)*UNITR.UNI NEG, SET GONEPAST
		BMN	EXIT
			V
			VQUIT
			STEER
			GONEPAST
			GONEGLAD
			RT
			UNITR
			UNI		# (MIGHT SAVE THIS FROM EARLIER..
			SETGPAST
		
		CS	NEG14
BACK		TS	JJ

		CS	V
		INDEX	JJ
		AD	VREFER		# VREF - V, HIGHEST VREF AT END OF TABLE.
		CCS	A		# IF VREF-V POS LOOP BACK
		CCS	JJ		# DECREMENT JJ, JJ CANNOT BE ZERO
		TC	BACK
		
		AD	ONE
		TS	TEM1B		# V-VREF UN TEM1B (MUST BE POSITIIVE NUM)
		
		INDEX	JJ
		CS	VREFER
		INDEX	JJ
		AD	VREFER +1	# V(K+1) - V(K)     (POS NUM)
		XCH	TEM1B
		EXTEND
		DV	TEM1B
		TS	GRAD		# GRAD = (V-VREF)/(VK+1 - VK)   (POS NUM
		
		CAF	FIVE
BACK2		TS	M1
		CAF	DEC15
		AD	JJ
		TS	JJ
		INDEX	A
		CS	VREFER
		INDEX	JJ
		AD	VREFER +1	# X(K+1) - X(K)
		EXTEND
		MP	GRAD
## Page 724
		INDEX	JJ
		AD	VREFER
		INDEX	M1
		TS	FX		# FX = AK + GRAD (AK+1 - AK)
		CCS	M1
		TC	BACK2
		
		CS	FX +1		# DON'T DESTROY FX +1
		COM
		AD	D
		EXTEND
		MP	FX +5		# F1
		TS	TEM1B		# TEM1B= F1(D-DREF)
		
		CS	RDOT		# FORM RDOTREF - RDOT
		DOUBLE
		DOUBLE			# SCALE UP BY 8 FOR THIS PHASE.
		DOUBLE
		AD	FX +3		# RDOTREF
		EXTEND
		AD	FX +4		# F2
		AD	TEM1B		# ADD F2(DADV1-DADVR)
		AD	FX +2		# RTOGO
		XCH	PREDANG		# NO OVERFLOW SKIP PLEASE.
		TC	INTPRET
		
		SMOVE	1
		TSRT	BDSU		# THETAH - PRED ANGLE
			PREDANG
			3
			THETAH
		
		SMOVE	3
		BDDV	TSLT
		BOV	DAD
		BOV
			FX		# FX = DRANGE/D L/D = Y
			-
			5
			GOMAXL/D
			LOD
			GOMAXL/D
		STORE	L/D
		
		ITC	0
			GLIMITER
		
GOPOSLAD	DMOVE	0
			LAD
		STORE	L/D
## Page 725
		ITC	0
			LIMITL/D

SETGPAST	SWITCH	0		# SHOULD BE BY TARGET IF HERE.
			GONEPAST

GONEGLAD	COMP	0
			LAD		# L/D = - LAD
		STORE	L/D
		
		ITC	0
			GLIMITER

GOMAXL/D	RTB	1
		DMP			# L/D = LAD SIG(MPAC)
			SIGNMPAC
			LAD
		STORE	L/D		# AND FALLS INTO LIMITL/D SECTION.

GLIMITER	DSU	2		# IF GMAX/2-D POS, GO TO LIMITL/D
		BPL	DAD		# IF GMAX-D NEG, GO TO GOPOSLAD
		BMN	DMP
			GMAX/2
			D
			LIMITL/D
			GMAX/2
			GOPOSLAD
			2HS		# 2HS(GMAX-D) INTO PD
		
		DMP	1
		DAD	DMP
			LEQ
			1/GMAX
			LAD		# 2HS(GMAX-D) (LEQ/GMAX+LAD) INTO PD
		
		DDV	2
		DAD	SQRT		# XLIM = SQRT(PD+(2HSGMAX/V)SQ)
		DAD	BMN		# IF RDOT+XLIM NEG, L/D=LAD
			2HSGMXSQ
			VSQUARE
			-
			RDOT		# KGLIM2= -5 SCALED
			GOPOSLAD

## Page 726

# COMES HERE TO COMPUTE ROLL COMMAND, CHECK LATERAL ERRORS, AND STEER
LIMITL/D	TEST	1		# NO LATERAL CONTROL IF PAST TARGET
		DMP	DAD		# Y = KLAT VSQUARE + LATBIAS
			GONEPAST
			L355
			VSQUARE
			KLAT
			LATBIAS
		STORE	Y
		
L350		ABS	4		# IF ABS(L/D)-L/DCMINR NEG, GO TO L353
		DSU	BMN
		LODON	SIGN		# IF K2ROLL LATANG NEG, GO TO L357
		BMN	LODON
		TSRT			# Y = Y/2
			L/D
			L/DCMINR
			L353
			LATANG
			K2ROLL
			L357
			Y
			1
		STORE	Y

L353		SIGN	2		# IF LATANG SIGN(K2ROLL) - Y POS, SWITCH
		DSU	BMN		# IF POS, GO TO BL361 IN BASIC.
		RTB
			LATANG
			K2ROLL
			Y
			L355
			BL361

L355		DDV	2		# ROLLC = ACOS((L/D)/LAD)
		TSRT	ACOS
		SIGN			# ROLLC = ROLLC SIGN(K2ROLL)
			L/D
			LAD
			1
			K2ROLL
		STORE	ROLLC
## Page 725

STEER		EXIT	0
STEER2		CAF	BIT12		# 1/8 TH.
		EXTEND
		MP	ROLLC		# SCALE ROLL OUTPUT FOR 16 SPEED.
		TS	MPAC
		
		CAF	BIT11		# 1/16 TH.
		EXTEND
		MP	ROLLBIAS	# BIAS AOG FROM LIFT UP ORIENTATION
		AD	MPAC		# ROLL = ROLLC/8 + ROLLBIAS/16 + K1ROLL
		AD	K1ROLL
		TS	MPAC		#  AFRAID TO STORE POSS BAD NUM IN THETAD
		TC	+4		#  SKIPS ON OVERFLOW
		INDEX	A
		CAF	LIMITS		#  ALLOW OVERFLOW (GO TO NEGMAX FROM POSMX
		AD	MPAC
		
		INHINT
		TS	THETAD		#  THETAD = X CDU = ROLL
		CS	BIT3
		MASK	TMMARKER
		AD	BIT3		#  SET BIT 3 IN TMMARKER WHEN THETAD COMP
		TS	TMMARKER
OVERNOUT	TC	PHASCHNG	# RECYCLE GROUP 5 TO PIPUP WAIT STATE.
		OCT	04105		# 5.12 RESTART.  (PIPUP SYNCED WITH 2 SEC)
		
		TC	GRABDSP
		TC	ENDENTRY
		
		CAF	V06N62		# DISPLAY TIME, VELOCITY, AND THETAH
		TC	NVSUB
		TC	RELDSPON
		
		TC	FREEDSP

ENDENTRY	TC	ENDOFJOB



V06N62		OCT	00662

## Page 728

BL361		CS	K2ROLL		# K2ROLL = - K2ROLL
		TS	K2ROLL
		
		CCS	L/D		# IF L/D POS, EXIT
		TC	RE-ENTER	# SO IT WONT STORE IN PUSH LIST.
		TC	RE-ENTER
		TC	+2
		TC	RE-ENTER
		
		CCS	K2ROLL		# K1ROLL = K1ROLL + K3ROLL SIGN(K2ROLL)
		CAF	K3ROLL		# K3ROLL = - .125
		TC	+2
		CS	K3ROLL
		AD	K1ROLL
		TS	K1ROLL
		TC	RE-ENTER	# SKIPS THIS ON OVERFLOW.
		
		INDEX	A		# POSMAX + 1 = NEGMAX  ETC.
		CAF	LIMITS		# NO LIMIT ON NUMBER OF ROLL REVS DURING
		AD	K1ROLL		#     ENTRY.   (ROUTINE IS GENERAL.)
		TS	K1ROLL		# STILL DOESNT WORRY ABOUT 2SCOMP, THO.
		TC	RE-ENTER



L357		SIGN	0
			L/DCMINR	# L/D = L/DCMINR SIGN(L/D)
			L/D
		STORE	L/D
		
		ITC	0
			L355

## Page 729

#	ROUTINE TO PREDICT AND SET PITCH ANGLE FOR 2ND ENTRY CONDITIONS.

UPTHETA3	CAF	PRIO14
		TC	FINDVAC
		CADR	UPTHETA1
		
		TC	TASKOVER
		
UPTHETA1	TC	INTPRET		#  STARTS OFF IN BASIC

UPTHETA		ITC	0		# FIND DESIRED SPACECRAFT ORIENTATION.
			GETUNB
		
		ITC	0		# GET OGC, IGC, MGC.,GIMBAL COMMANDS
			CALCGTA
		
		DSU	1		# GET UNCORRECTED ROLLBIAS
		EXIT
			OGC
			ROLLCTEM
		
		XCH	MPAC
		DOUBLE
		TS	MPAC +2
		TC	+4		# OVERFLOW CORRECT
		INDEX	A
		CAF	LIMITS
		AD	MPAC +2
		
		XCH	ROLLBIAS	# STORE NEW VALUE AND FETCH OLD.
		COM
		TS	MPAC +2
		AD	ROLLBIAS
		TS	A		# LIMIT CHANGE IN ROLLBIAS TO 180 DEG.
		TC	+3
		
		CS	MPAC +2
		TS	ROLLBIAS	# USE OLD VALUE IF TOO BIG.
		
		CS	IGC
		COM
		DOUBLE
		XCH	THETAD +1	# COMMAND PITCH ANGLE. (NO SKIPS)
		
		CS	MGC
		COM
		DOUBLE			# CHANGE FROMINTERPRETER SCALING TO CDU
		XCH	THETAD +2	# YAW, MG ANGLE COMMAND
		
		INHINT
## Page 730
		CAF	PITCHDT		# CALL UP ATTITUDE CONTROL LOOP PITCHDT
		TC	WAITLIST	# SECONDS AFTER FINISHING THIS TIME.
		CADR	UPTHETA3

UPNOVER		TC	ENDOFJOB



PITCHDT		DEC	3

## Page 731

#   PIPAS ARE READ (BUT NOT CLEARED) AT A HIGHER RATE HERE.

INTERPIP	CS	PIPAX
		INDEX	PIPCTR
		TS	XPIPBUF
		CS	PIPAY
		INDEX	PIPCTR
		TS	YPIPBUF
		CS	PIPAZ
		INDEX	PIPCTR
		TS	ZPIPBUF
		
		CCS	PIPCTR
		TC	+4
		CAF	TWO
		TS	PIPCTR
		TC	TASKOVER	# WOULD GO TO PIPSETUP IF SMOOTHER WRITTEN
		TS	PIPCTR
		
		CAF	IPIPDT1
		TC	WAITLIST
		CADR	INTERPIP
		
		TC	TASKOVER



PIPSETUP	CAF	PRIO15		# LOWER THAN AVG G - HIGHER THAN UPTHETA.
		TC	NOVAC
		CADR	SMOOTHER
		TC	TASKOVER



SMOOTHER	TC	ENDOFJOB	# WHEN WRITTEN, FIND A GOOD BANK FOR THIS.



IPIPDT1		DEC	50

## Page 732

# DETERMINE TIME TO OPEN CHUTE HERE IF NEEDED

		BANK	27

DT		DEC	200		# MAIN LOOP DT.
DEC15		DEC	15

K3ROLL		DEC	-.125

# DEFINED BY EQUALS

ASP		EQUALS	0
Y		EQUALS	20D		# TEMP
GAMMAL1		EQUALS	22D
A1		EQUALS	FX

## Page 733

# 	TABLE USED FOR SUB-ORBITAL REFERENCE TRAJECTORY CONTROL.



VREFER		DEC	0		# REFERENCE VELOCITY SCALED V/51532.3946
		DEC	.006539		# 15 POINTS ARE STORED AS THE INDEPENDENT
		DEC	.020958		# VARIABLE AND THEN SIX 15 POINT FUNC-
		DEC	.040809		# TIONS OF V ARE STORED CONSECUTIVELY
		DEC	.076107
		DEC	.122156
		DEC	.165546
		DEC	.196012
		DEC	.271945
		DEC	.309533
		DEC	.356222
		DEC	.404192
		DEC	.448067
		DEC	.456023
		DEC	.67918		# HIGH VELOCITY FOR SAFETY
		
		DEC	-.008035	# DRANGE/DA	SCALED DRDA/(2700/805)
		DEC	-.008035
		DEC	-.010820
		DEC	-.016550
		DEC	-.026935
		DEC	-.042039
		DEC	-.058974
		DEC	-.070721
		DEC	-.098538
		DEC	-.107482
		DEC	-.147762
		DEC	-.193289
		DEC	-.602557
		DEC	-.99999
		DEC	-.99999
		
		DEC	0		# -DRANGE/DRDOT
		DEC	0		# SCALED((2VS/8 2700) DR/DRDOT)
		DEC	-.0494520 B-3
		DEC	-.0683663 B-3	
		DEC	-.1343468 B-3
		DEC	-.2759846 B-3
		DEC	-.4731437 B-3
		DEC	-.6472087 B-3
		DEC	-1.171693 B-3
		DEC	-1.466382 B-3
		DEC	-1.905171 B-3
		DEC	-2.547990 B-3
		DEC	-4.151220 B-3
		DEC	-5.813617 B-3
## Page 734
		DEC	-5.813617 B-3

		DEC	-.00642065 B3	# RDOTREF	SCALED (8 RDT/2VS)
		DEC	-.00642065 B3
		DEC	-.0134426  B3
		DEC	-.013947   B3
		DEC	-.013462   B3
		DEC	-.011813   B3
		DEC	-.0095631  B3
		DEC	-.00806946 B3
		DEC	-.006828   B3
		DEC	-.00806946 B3
		DEC	-.0109791  B3
		DEC	-.0151496  B3
		DEC	-.0179817  B3
		DEC	-.0159061  B3
		DEC	-.0159061  B3
		
		DEC	0		# RANGE TO GO SCALED RTOGO/2700
		DEC	0
		DEC	.00100		#	2.7 NM
		DEC	.0032963	#	8.9
		DEC	.0081852	#	22.1
		DEC	.017148
		DEC	.027926
		DEC	.037
		DEC	.063296
		DEC	.077889
		DEC	.098815
		DEC	.127519
		DEC	.186963
		DEC	.238148
		DEC	.238148
		
		DEC	-.042360	# -AREF   SCALED AREF/805
		DEC	-.042360
		DEC	-.052919
		DEC	-.074534
		DEC	-.101242
		DEC	-.116646
		DEC	-.122360
		DEC	-.127081
		DEC	-.147453
		DEC	-.155528
		DEC	-.149565
		DEC	-.118509
		DEC	-.034907
		DEC	-.007950
		DEC	-.007950

## Page 735
		DEC	.000371		# DRANGE/D L/D SCALED Y/2700
		DEC	.000371
		DEC	.004770
		DEC	.008081
		DEC	.016030
		DEC	.035815
		DEC	.069422
		DEC	.104519
		DEC	.122
		DEC	.172407
		DEC	.252852
		DEC	.363148
		DEC	.512963
		DEC	.558519
		DEC	.558519		# END OF STORED REFERENCE
		
## Page 736

#    CONTINUATION OF RE-ENTRY SECTION IN 2ND BANK.  (CONSTANTS AND M923=8

		BANK	30
NEARONE		2DEC	.999999999
1/3RD		2DEC	.333333333	# 	ONE THIRD
1/12TH		2DEC	.0833333333	# ONE TWELFTH
# VSAT = 25766.1973 FT/SEC.

# RE = 21,202,900  FEET

LEWD1		2DEC	.1
LEWD2		2DEC	.2
FOURTH		2DEC	.25
3ZEROS		2DEC	0
1BITDP		2OCT	0000000001	# DOUBLE PREC 1 BIT
		DEC	0
NEAR1/4		2OCT	0777700000	# 1/4 LESS 1 BIT IN UPPER PART.
C18		2DEC	.0097026346	# 500/2VS
KDMIN		2DEC	.00062111801	# .5/805
C1/16		2DEC	.0625		# 1/16
Q2		2DEC	-.046388889	# -1002/21600 =(643/21600-Q2(23500/2VS))
Q3		2DEC	.167003132	# .07 2VS/21600
Q5		2DEC	.326388889	# .3 23500/21600
Q6		2DEC	.034893617	# 820/23500
Q7F		2DEC	.0074534161	# 6/805    (VALUE OF Q7 IN FIXED MEM.)
VMIN		2DEC	.34929485	# 18000/2VS
C12		2DEC	.00684572901	# 32 28500/(21102900 2 PI)
KB1		2DEC	.29411765	# 1/3.4
KB2		2DEC	-.0057074322 B4	# -16/(.0034 2 VS)
## Page 737
C19		2DEC	.16149068	# 130/805
VCORLIM		2DEC	.019405269	# 1000/2VS
VQUIT		EQUALS	VCORLIM		# BOTH ARE 1000 FT/SEC
C20		2DEC	.21739130	# (175 FPSS) LIFT UP IF ABOVE C20
25NM		2DEC	.0011574074 B-4	# 25/(21600 16)		(25 NAUT MILES)
K1D		2DEC	.0314453125	# .01 805/256
K2D		2DEC	-.201298418	# -.001 2VS/256
KVSCALE		2DEC	.81491944	# 12800/(2 VS .3048)
KASCALE		2DEC	.97657358	# 5.85 16384/(4 .3048 100 805)
KTETA		2DEC*	.383495203 E2 B-14*	#  1000 2PI/16384(163.84)
KT		2DEC*	.157788327 E2 B-14*	# RE(2PI)/2VS(16384)163.84
.05G		2DEC	.002		# .05/25
LAD		2DEC	.3
LAD/256		2DEC	.001171875	# .3/256
KLAT		2DEC	.0125
LATBIAS		2DEC	.00003		# APPRX .5 NM/ 4(21600/2 PI)
KWE		2DEC	.120056652
KACOS		2DEC	.004973592	# 1/32(2PI)
CHOOK		2DEC	1 B-5		# .25/8
CH1		2DEC	.24		# 8 CH1/25		(CH1 = .75)
KC3		2DEC	-.082540747	# KC3 (2VS)SQ /2PI 2S 32.2 LAD R
LOD		2DEC	.18
VRCONT		2DEC	.0135836886	# 700/2 VSAT
HALVE		2DEC	.5
## Page 738
NEG1/8		EQUALS	K3ROLL		# ONLY A SINGLE PRECISION NUMBER.
L/DCMINR	2DEC	.2895		# LAD COS(15 DEG)
C/D0		2DEC	-.00387019231
GMAX/2		2DEC	.2		# 5/25
1/GMAX		2DEC	.4
2HS		2DEC	.0172786611	# 2 28500 25 32.2/(4 VS VS)
2HSGMXSQ	2DEC	.000047768341	# ((2 28500 322/(4VS VS))SQ
KWIEM		2DEC	.147323336	# RESULT IN METERS OVER 12800
COS(13)		2DEC	.9763		# REAL COS OF 12.5 DEG. NOT 1/2 COSINE.
-SIN(13)	2DEC	-.21644		# REAL SIN OF 12.5 DEG.  NO FACTOR OF 1/2


2C1HS		2DEC	.0215983264	# 2 1.25 28500 805/(2 VS)SQ
2C1HSLAD	2DEC	.071994421	# 2 1.25 28500 805/(.3 4 VS VS)
POINT1		2DEC	.1
K44		2DEC	.00175626224	# 2 VS/(156 57.3 57.3 57.3)
VFINAL		2DEC	.48513173	# 25000/2 VS
KAT		2DEC	.08		# 2 G-S (2/25)
POINT8		2DEC	.8
POINT2		2DEC	.2
Q7MIN		2DEC	.043478261	# 35/805
PT1/16		2DEC	.00625

# ... END OF RE-ENTRY CONSTANTS ...

## Page 739

#	CLOSED SUBROUTINE TO COMPUTE DESIRED NAV BASE ORIENTATION
#	NEEDED DURING ENTRY PHASE.
#
#	ENTER WITH VN, UNITR, UNITW, AND ROLLC
#	COMPUTES UXNB, UYNB, AND UZNB.  (NAV BASE UNIT VECTORS)



GETUNB		RTB	3		# RESET PUSH COUNTER.
		VXV	VXSC		# GET VELOCITY OF ATMOSPHERE
		VAD	UNIT		# GET UVA., RELATIVE VELOCITY
		VXSC			# RESOLVE BY COS OF 13 DEG.
			FRESHPD
			UNITR
			UNITW		# NEG OF REAL VEL.
			KWIEM		# EARTH RATE CONST IN METERS X 4.
			VN
			COS(13)		# UVA COS(13) INTO PD.
		
		NOLOD	1
		VXV	UNIT		# UYA = UNIT(VA*RN)
			UNITR
		STORE	16D		# UYA INTO LOC 16 OF VAC AREA.
		
		DMOVE	0		# SAVE ROLLC SO THAT IT CANNOT CHNGE
			ROLLC		#   DURING THIS SUBROUTINE
		STORE	ROLLCTEM	# INTO LOC 14 OF PUSH LIST
		
		NOLOD	1		# COS(ROLLC)
		COS	VXSC		# UYA COS(ROLLC).  PUSH INTO LOC 6.
			16D
		
		SIN	0
			ROLLCTEM	# SIN(ROLLC) INTO PD AT LOC 12.
		
		VXV	2		# UNA = UNIT(UYA*UVA)
		UNIT	VXSC		# UNB = UYA COS(ROLL) + UNA SIN(ROLL)
		VAD	UNIT		# UNIT COULD BE REPLACED BY  VSLT   1.
			16D		#   UYA STORED AT LOC 16
			0		# UVA FIRST ITEM INTO PUSH LIST
		STORE	UYNB		# 1 SCAL AND  1 VEC FROM PD.
		
		NOLOD	2
		VXV	UNIT		# UN = UNIT (UYNB*UVA)
		VXSC	VSU		# UXNB = -UN SIN(13) -UVA COS(13)
			0
			-SIN(13)	# PULLS UVA COS(13) FROM PD.
		STORE	UXNB
		
		NOLOD	1
## Page 740
		VXV	VSLT		# UZNB = UXNB*UYNB
			UYNB
			1
		STORE	UZNB
		
		ITCQ	0		# AND RETURN.



ROLLCTEM	EQUALS	14D

## Page 741

#    SUBROUTINE TO READ PIPA COUNTERS, TRING TO BE VERY CAREFUL SO THAT
# IT WILL BE RESTARTABLE.
#
#	(ARRIVE IN INTERRUPTED STATE OR INHIBITED AFTER RESTART.)
#    (EXIT IS THRU  ISWRETRN)

PIPASR		CS	ZERO		# PUT THESE INTO THE IMPOSSIBLE STATE
		TS	TEMX		# FOR THEIR INITIAL VALUES.
		TS	TEMY
		TS	TEMZ
		CAF	ZERO
		TS	DELVX +1
		TS	DELVY +1	# PIP COUNTERS MAY NOT HAVE POS ZERO IN
		TS	DELVZ +1
		TS	PIPAGE		# ZERO THIS TO INDICATE IN PIPA READING.

REPIP1		TC	READTIME +1	# PROBABLY NOT NEEDED SINCE NOT MUCH
		CS	RUPTSTOR +1	# CHANCE OF TIME1 OVERFLOWING NOW.  (BUT
		TS	PIPTIME +1	# JUST POSSIBLE IF MANY RESTARTS.
		CS	RUPTSTOR
		TS	PIPTIME
		
		CS	PIPAX
		TS	TEMXY
		XCH	TEMX		# PUT NEGZERO INTO PIPACTRS AS READ.
		XCH	PIPAX
REPIP1B		TS	DELVX
		TS	DELVX +1	# DOUBLE SAVE.

REPIP2		CS	PIPAY
		TS	TEMXY
		XCM	TEMY
		XCH	PIPAY
REPIP2B		TS	DELVY
		TS	DELVY +1

REPIP3		CS	PIPAZ		# REPEAT PROCESS FOR Z PIPA.
		TS	TEMXY		# SAVE NEG OF PIPA READ
		XCH	TEMZ		# SAVE HERE AS PICK UP NEGZERO
		XCH	PIPAZ		# RESETTING PIPA AS READ OUT)
REPIP3B		TS	DELVZ		# AND STORE IN Z.
		TS	DELVZ +1	# SHOWS THAT IT REALLY MADE IT.

REPIP4		CS	ZERO		# LEAVE THEM AT NEGZERO
		TS	DELVX +1
		TS	DELVY +1
		TS	DELVZ +1
		CS	BIT1
		MASK	TMMARKER
		AD	BIT1		# SET BIT 1 IN TM MARKER.
## Page 742
		TS	TMMARKER
		TC	ISWRETRN	# AND EXIT.  SHOULD HAVE COME THRU ICALL

## Page 743

#	ROUTINE TO RESTART IF READING PIPA COUNTERS.

REPIPASR	CCS	PIPAGE		# WAS I READING PIPS.
		TC	PIPASR		# NO.. PIPAGE = PLUS CONST.
		CCS	DELVZ +1	#  PIPAGE = 0  (I WAS READING PIPS.)
		TC	REPIP4		#  Z WAS READ OK.
		TC	+3		#  Z NOT DONE, CHECK Y.
		TC	REPIP4
		TC	REPIP4
		CCS	DELVY +1	# HAS IT CHANGED FROM ITS +ZERO INIT VALU
		TC	+3		# YES, Y DONE. TRY TO REDO Z.
		TC	CHKDELVX	# NO, GO LOOK AT X.
		TC	+1		# YES.
		CCS	TEMZ		# DOES TEMZ STILL = -0.
		TC	+4		# NO TRY TO RESTORE
		TC	+3
		TC	+2
		TC	REPIP3		# YES, GO BACK AND READ Z AGAIN.
		CS	TEMXY		# MUCH MORE LOGIC COULD BE INCORPORATED
		TC	REPIP3B		# TO CHECK PIPA CTR FOR SIZE.

CHKDELVX	CCS	DELVX +1	# HAS THIS CHANGED.
		TC	+3		# YES
		TC	CHKTEMX		# NI.
		TC	+1		# YES
		CCS	TEMY
		TC	+4
		TC	+3
		TC	+2
		TC	REPIP2
		CS	TEMXY
		TC	REPIP2B

CHKTEMX		CCS	TEMX		# HAS THIS CHANGED.
		TC	+4		# YES
		TC	+3		# YES
		TC	+2		# YES
		TC	REPIP1		# NO
		CS	TEMXY
		TC	REPIP1B

## Page 744

#  ENTRY INITIALIZATION ROUTINE.
#  -----------------------------
STARTENT	TC	PHASCHNG	# KEEP UPTHETA RUNNING IN CASE OF RESTART
		OCT	03204		# 4.26 RESTART.
		
		TC	PHASCHNG	# PICK UP CURRENT STRING AT NEWMODE63.
		OCT	02305		# 5.19 RESTART.  RESYNCING PIPUP ALSO.
		
		INHINT
		CAF	PRIO24		# ESTABLISH UPTHETA FOR 1ST TIME.
		TC	FINDVAC
		CADR	UPTHETA1	# START UPTHETA JOB.
		
		RELINT
NUMODE63	TC	NEWMODE
		OCT	00063		# ENTRY PHASE = MODE 63
		
		CAF	INITCADR
		TS	GOTOADDR
		CAF	EARGCADR
		TS	CALCG
		CAF	ZERO
		TS	TENTRY
		TS	ROLLBIAS
		CAF	NUDELTAT
		TS	DELTAT
		CAF	NU/PIPDT
		TS	1/PIPADT
		CS	ENTMASK
		INHINT			# INITIALIZE SWITCHES (BITS6:10,15 IN
		MASK	STATE		# STATE) 6=GONEPAST,7=RELVELSW,8=EGSW
		AD	ENTRYSW		# 9=HUNTSW1, 10=HIND, 15=INRLSW
		TS	STATE		# ALL BUT RELVELSW SET TO NON-BRANCH (1)
		RELINT
		TC	INTPRET
		
		RTB	2		# SET CDUX AGAIN JUST IN CASE.
		VXV	DOT
		COMP	RTB
			CDUXFIX
			VN
			UNITR
			RTINIT		# THIS GIVES LATANG.
			SIGNMPAC	# GETS SIGN OF MPAC
		STORE	K2ROLL		# K2ROLL = -SIGN(LATANG)
		
		DOT	1
		TSLT	ACOS
			UNITR
			RTINIT
## Page 745
			1
		STORE	THETAH
		
		VMOVE	0
			RT
		STORE	RTINIT
		
		COMP	0
			DTEAROT
		STORE	DTEAROT
		
		ITC	0
			EARROT1
		RTB	0
			OVERNOUT	# EXIT SETTING RESTART BITS TO 5.12 FOR EN



INITCADR	CADR	INITROLL
EARGCADR	CADR	CALCGEAR
NUDELTAT	DEC	200 B5
NU/PIPDT	DEC	200 B6
ENTMASK		OCT	01741
ENTRYSW		OCT	01341
